<?php
header("Content-type:text/html;charset=utf-8");
if(!$d = @mysql_connect('127.0.0.1','root','admin888')){
	echo mysql_error();
	exit;
}

if(!mysql_select_db('c50')){
	echo mysql_error();
	exit;
}
//告诉服务器，发送的文字是UTF8，服务器到时返回数据也是UTF8
mysql_query("set names utf8");

$d = mysql_query("insert into stu set sname='小苹果',age='1992-2-11',sex=1");
// var_dump(mysql_insert_id());

// 更新
// $d = mysql_query("update stu set class_id=1 where class_id is null");
//受影响的行数  增、删、改  没有查
// var_dump(mysql_affected_rows());


//查询语句 
$result = mysql_query("select * from stu");

while($row = mysql_fetch_array($result,MYSQL_BOTH))
{
	$rows[]=$row;	
}
// mysql_close($d);
?>
<table border="1" >
	<tr>
		<td>ID</td>
		<td>学生名称</td>
		<td>生日</td>
		<td>性别</td>
	</tr>
	<?php foreach($rows as $f):?>
	<tr>
		<td><?php echo $f['id'];?></td>
		<td><?php echo $f['sname'];?></td>
		<td><?php echo $f['age'];?></td>
		<td><?php echo $f['sex'];?></td>
	</tr>
	<?php endforeach;?>
</table>
共有:<?php echo mysql_num_rows($result);?>条
















